<?php

/**
 * 用户操作模块
 *
 * Created by PhpStorm.
 * User: evan
 * Date: 2016/12/22
 * Time: 下午10:33
 */
class Opera extends MY_Api_Controller
{
    /**
     * 修改个人资料
     */
    public function modify()
    {
        $uid = $this->uid;


        $param = array
        (
            'nickname'      => trim($this->input->get_post('nickname')),
            'recommend_uid' => (int)$this->input->get_post('recommend_uid'),
            'occupation'    => (int)$this->input->get_post('occupation'),
            'introduction'  => trim($this->input->get_post('introduction')),
            'add_data'      => trim($this->input->get_post('add_data')),
            'sex'           => $this->input->get_post('sex'),
            'header'        => (int)$this->input->get_post('header'),
            'video'         => (int)$this->input->get_post('video'),
        );


        //处理性别传空的
        if ('' == $param['sex'])
        {
            unset($param['sex']);
        }


        $this->load->service('user/service_user_opera');
        $data = $this->service_user_opera->modify($uid, $param);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 用户绑定手机号码
     */
    public function bind_mobile()
    {
        $uid    = $this->uid;
        $mobile = trim($this->input->get_post('mobile'));
        $code   = trim($this->input->get_post('code'));


        $this->load->service('user/service_user_opera');
        $data = $this->service_user_opera->bind_mobile($uid, $mobile, $code);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 验证原手机号码
     */
    public function verify_raw_mobile()
    {
        $uid        = $this->uid;
        $mobile     = trim($this->input->get_post('mobile'));
        $code       = trim($this->input->get_post('code'));


        $this->load->service('user/service_user_opera');
        $data = $this->service_user_opera->verify_raw_mobile($uid, $mobile, $code);


        $this->json_output($data['data'], $data['status']);
    }


}